#include <stdio.h>
#include <time.h>

int main () {
	FILE *fp = NULL;

	time_t timep;
	struct tm *p;
	char name[256] = {0};

	time(&timep);//获取从1970至今过了多少秒，存入time_t类型的timep
	p = localtime(&timep);//用localtime将秒数转化为struct tm结构体

	sprintf(name, "%d%d%d%d%02d.bin", 1900 + p->tm_year, 1 + p->tm_mon, p->tm_mday, p->tm_hour, p->tm_min); //把格式化的时间写入字符数组中

	printf("创建文件名称为：%s\n", name);
	if ((fp = fopen(name, "w")) == NULL)
		perror("");

	fclose(fp);

	return 0;
}
